using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace One_Crappy_RPG
{
    public class BattleText
    {
        string _text;
        public Vector2 Position = Vector2.Zero;
        public Color Color;
        float Life = 1.0f;
        public float ElapsedTime;

        public BattleText(int amount, EffectDamage.DamageType type)
        {
            _text = amount.ToString();

            if (amount < 0)
            {
                Color = new Color(0, 255, 0, 255);

                //Trim off the negative sign
                _text = _text.Remove(0, 1);
            }
            else if (type == EffectDamage.DamageType.Physical ||
                type == EffectDamage.DamageType.None)
                Color = Color.White;
            else if (type == EffectDamage.DamageType.Fire)
                Color = Color.Red;
            else if (type == EffectDamage.DamageType.Ice)
                Color = Color.Blue;
            else if (type == EffectDamage.DamageType.Earth)
                Color = Color.Brown;
            else if (type == EffectDamage.DamageType.Wind)
                Color = Color.Teal;
            else if (type == EffectDamage.DamageType.Magical)
                Color = Color.Purple;
            else if (type == EffectDamage.DamageType.Holy)
                Color = Color.Yellow;
            else if (type == EffectDamage.DamageType.Poison)
                Color = Color.YellowGreen;
            else
                Color = Color.White;
        }

        public string Text
        {
            set { _text = value; }
            get { return _text; }
        }

        public void Update(GameTime gameTime)
        {
            ElapsedTime += (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (ElapsedTime >= Life)
            {
                _text = "";
                ElapsedTime = -10.0f;
            }
        }

        public void Draw(SpriteBatch batch)
        {
            batch.DrawString(InputManager.Font, _text, Position, Color);
        }
    }
}
